﻿using Syncfusion.UI.Xaml.NavigationDrawer;
using System.Globalization;
using System.Windows.Data;

namespace Syncfusion.Lib.Converters
{
    /// <summary>
    /// 功能列转 NavigationItem ItemType
    /// </summary>
    [ValueConversion(typeof(IEnumerable<>), typeof(ItemType))]
    public class EnumerableToNavigationItemItemTypeConverter : IValueConverter
    {
        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            ItemType res = ItemType.Tab;
            if(value is IEnumerable<object>)
            {
                if(value is IEnumerable<object> list && list.Any())
                {
                    res = ItemType.Button;
                }
            }
            return res;
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            return "";
        }
    }
}
